<template>
    <view style="width: 100vw;height:100vh;">
        <u-navbar title="新增分类"></u-navbar>
        <div class="form-box">
            <u-form :model="form" ref="form" label-position="top">
                <u-form-item label="分类名称" prop="name"><u-input v-model="form.name" /></u-form-item>
            </u-form>
        </div>
        <div class="bottom-btn">
            <u-button class="btn" type="primary" @click="submit">提交</u-button>
        </div>
    </view>
</template>
<script lang="ts" setup>
import { ref, reactive } from 'vue';
import config from '../../config/index'
const form = reactive({
    name: ''
})

const submit = async () => {
    await uni.request({
        url: `${config.baseUrl}/category/create`,
        method: 'post',
        data: form,
    })
    uni.showToast({
        title: '创建成功',
        icon: 'success'
    })
    uni.navigateBack()
}

</script>
<style lang="scss" scoped>
.home-contirner {
    margin: 10rpx;

}

.form-box {
    margin: 10px;
}

.bottom-btn {
    position: absolute;
    bottom: 0px;
    width: 100%;
    padding: 10rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10rpx;

    .btn {
        width: 100vw;
    }
}
</style>